package edu.ccut.saturn.workflow.activity.execute;

import java.util.List;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.workflow.model.ActivityInfo;
import edu.ccut.saturn.workflow.model.WorkFlowInfo;

public class GetViewerPath extends DefaultComponent {
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		WorkFlowInfo workflowInfo = (WorkFlowInfo)parameterContext.getParameterValue(0);
		String activity_define_id = (String)parameterContext.getParameterValue(1);
		List<ActivityInfo> actlist = workflowInfo.getActivities();
		String url = null;
		for(ActivityInfo activity : actlist){
			if(activity_define_id.equals(activity.getId())){
				if(activity.getUrl()!=null&&!activity.getUrl().equals(""))
				url = activity.getUrl();
//				if(url==null||"".equals(url)){
//					url="/edu.ccut.saturn.workflow/page/ShowFormForExecuteActivity.jsp";
//				}
				break;
			}
		}
		parameterContext.setParameter(2, url);
		
	}
}